https://stackoverflow.com/questions/33281419/updating-post-in-frontend-send-post-id-to-functions-php

<?php $current_post = $post->ID; ?> 
<form action="" method="post">
    <input type="text" name="title" value="<?php echo $title; ?>">
    <textarea name="text"><?php echo $content; ?></textarea>
    <input type="submit" value="edit post">
    <?php wp_nonce_field( 'edit_post', 'edit_post_nonce' ); ?>
    <input type="hidden" name="edit_post" value="true" />
</form>




function edit_post_foo($query){
   $id = get_the_id();

   $post = array(
        'ID' => $id,
        'post_type'     => 'post',
        'post_title'    => wp_strip_all_tags($_POST['title']),
        'post_content'  => wp_strip_all_tags($_POST['text']),
        'post_status'   => 'publish'
    );

    $post_id = wp_update_post( $post );

    if ( $post_id ) {
        wp_redirect( $_SERVER['HTTP_REFERER'] );
        exit;
    }
}

if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['edit_post'] )) {

    if ( ! isset( $_POST['edit_post_nonce'] ) ) {
        return;
    }

    if ( ! wp_verify_nonce( $_POST['edit_post_nonce'], 'edit_post' ) ) {
        return;
    }

    if ( isset( $_POST['post_type'] ) && 'post' == $_POST['post_type'] ) {

        if ( ! current_user_can( 'edit_posts' ) ) {
            return;
        }
    }

    if(empty(trim($_POST['title']))){
        $erro = "inform a title.";
        return;
    }

    if(empty(trim($_POST['text']))){
        $erro = "sen a text.";
        return;
    }

    add_action("wp", "edit_post_foo");
}






*******************************************************

 maybe find a solution.

First, in your form add an input type with name="action" and value="your_custom_function"

Then

Create your function in your functions.php


function your_function($query)
{
   $id = get_the_id();

   // do something

   wp_redirect( $_SERVER['HTTP_REFERER'] );
   exit;
}
if( isset($_POST["action"]) && $_POST["action"] == "your_custom_value" )
  add_action("wp", "your_function");